﻿using MPSystem.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using Ay.MvcFramework;
using Ay.Framework.DataCreaters;
using Ay.Framework.WPF.Controls;
using Newtonsoft.Json;
using System.Data;
using System.Collections;
using Ay.Framework.WPF;
using System.ComponentModel;
using Base.BLL;
using Base.DAL;
using System.Windows.Navigation;

namespace MPSystem.Controllers
{
    public class BasicDataSet_SystemController : Controller
    {
        
        //通用类型
        MPSystem.Models.Common common = new Common();
        private AyTableViewStatuss _TableStatus;
        public AyTableViewStatuss TableStatus
        {
            get { return _TableStatus; }
            set { Set(ref _TableStatus, value); }
        }
        private bool _IsBusy = false;
        public bool IsBusy
        {
            get { return _IsBusy; }
            set { Set(ref _IsBusy, value); }
        }
        #region 综采参数绑定
        /// <summary>
        /// 初始化左边
        /// </summary>
        public ZCYL_Left zcyl_left { get; set; } = new ZCYL_Left();

        //综采压力--右边
        public ObservableCollection<ZCYL_Right> Datas_ZCYL_Right { get; set; } = new ObservableCollection<ZCYL_Right>();
        //综采压力--下面
        public ObservableCollection<ZCYL_Bottom> Datas_ZCYL_Bottom { get; set; } = new ObservableCollection<ZCYL_Bottom>();

        /// <summary>
        /// 测区名称
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _CSCob = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> CSCob
        {
            get { return _CSCob; }
            set { Set(ref _CSCob, value); }
        }
        /// <summary>
        /// 工作面
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _GZMCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> GZMCbo
        {
            get { return _GZMCbo; }
            set { Set(ref _GZMCbo, value); }
        }
        /// <summary>
        /// 第一压力通道
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _FirCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> FirCbo
        {
            get { return _FirCbo; }
            set { Set(ref _FirCbo, value); }
        }
        /// <summary>
        /// 第二压力通道
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _SecCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> SecCbo
        {
            get { return _SecCbo; }
            set { Set(ref _SecCbo, value); }
        }
        /// <summary>
        /// 第二压力通道
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _ThirdCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> ThirdCbo
        {
            get { return _ThirdCbo; }
            set { Set(ref _ThirdCbo, value); }
        }
        /// <summary>
        /// 记录周期
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _WriteCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> WriteCbo
        {
            get { return _WriteCbo; }
            set { Set(ref _WriteCbo, value); }
        }
        /// <summary>
        /// 支架形式
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _StyleCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> StyleCbo
        {
            get { return _StyleCbo; }
            set { Set(ref _StyleCbo, value); }
        }


        /// <summary>
        /// 状态--右边
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _ZTCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> ZTCbo
        {
            get { return _ZTCbo; }
            set { Set(ref _ZTCbo, value); }
        }
        /// <summary>
        /// 状态--右边
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _WZCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> WZCbo
        {
            get { return _WZCbo; }
            set { Set(ref _WZCbo, value); }
        }


        #endregion
        #region 围岩移动参数绑定
        /// <summary>
        /// 初始化左边
        /// </summary>
        public WYYD_Left wyyd_left { get; set; } = new WYYD_Left();

        //综采压力--右边
        public ObservableCollection<WYYD_Right> Datas_WYYD_Right { get; set; } = new ObservableCollection<WYYD_Right>();
        //综采压力--右边
        public ObservableCollection<WYYD_Bottom> Datas_WYYD_Bottom { get; set; } = new ObservableCollection<WYYD_Bottom>();

        /// <summary>
        /// 围岩移动--巷道名称
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _XDCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> XDCbo
        {
            get { return _XDCbo; }
            set { Set(ref _XDCbo, value); }
        }


        #endregion
        #region 锚杆参数绑定
        /// <summary>
        /// 初始化左边
        /// </summary>
        public MG_Left mg_left { get; set; } = new MG_Left();

        //综采压力--右边
        public ObservableCollection<MG_Right> Datas_MG_Right { get; set; } = new ObservableCollection<MG_Right>();
        //综采压力--右边
        public ObservableCollection<MG_Bottom> Datas_MG_Bottom { get; set; } = new ObservableCollection<MG_Bottom>();
        /// <summary>
        /// 锚杆--巷道名称
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _XDCbo1 = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> XDCbo1
        {
            get { return _XDCbo1; }
            set { Set(ref _XDCbo1, value); }
        }
        /// <summary>
        /// 初始预警
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _csyjCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> CSYJCbo
        {
            get { return _csyjCbo; }
            set { Set(ref _csyjCbo, value); }
        }


        /// <summary>
        /// 报警值
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _bjzCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> BJZCbo
        {
            get { return _bjzCbo; }
            set { Set(ref _bjzCbo, value); }
        }
        /// <summary>
        /// 类型
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _lxCbo = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> LXCbo
        {
            get { return _lxCbo; }
            set { Set(ref _lxCbo, value); }
        }

        #endregion
        #region 围岩应力参数绑定
        /// <summary>
        /// 初始化左边
        /// </summary>
        public WYYL_Left wyyl_left { get; set; } = new WYYL_Left();

        //综采压力--右边
        public ObservableCollection<WYYL_Right> Datas_WYYL_Right { get; set; } = new ObservableCollection<WYYL_Right>();
        //综采压力--右边
        public ObservableCollection<WYYL_Bottom> Datas_WYYL_Bottom { get; set; } = new ObservableCollection<WYYL_Bottom>();

        /// <summary>
        /// 围岩应力--巷道名称
        /// </summary>
        private ObservableCollection<IAyCheckedItem> _XDCbo2 = new ObservableCollection<IAyCheckedItem>();
        public ObservableCollection<IAyCheckedItem> XDCbo2
        {
            get { return _XDCbo2; }
            set { Set(ref _XDCbo2, value); }
        }


        #endregion
        public ObservableCollection<AyTableViewSelectionMode> SelectionMode { get; set; } = new ObservableCollection<AyTableViewSelectionMode>();

    
        public BasicDataSet_SystemController() : base()
        {
            //加载UI
             
            //后台加载数据
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += (o, ea) =>
            {
                //no direct interaction with the UI is allowed from this method
                AyThread.Instance.RunNew(() =>
                {
                 
                    LoadData();

                });
                //CreateChartColumn("测试", strListx, strListy);
            };
            worker.RunWorkerCompleted += (o, ea) =>
            {
                //work has completed. you can now interact with the UI
                LoadUI();
                ViewBag.IsBusy = false;
            };
            //set the IsBusy before you start the thread
            ViewBag.IsBusy = true;
            worker.RunWorkerAsync();
            // 

            #region 测区变化 导致工作面/巷道数据源变化
            CQchange  = inParam =>
            {
                var _1 = inParam   ;
                var gzm = ConfigService.GetGZM(AyCommon.ToInt(_1));
                common.LoadCombox_IE(GZMCbo, gzm);//工作面
                if (gzm.Count() == 0)
                    zcyl_left.GZMBH = -1;
                else
                    zcyl_left.GZMBH = gzm.ElementAt(0).GZMBH;
            };
            WYYDchange = inParam =>
            {
                var _1 = inParam;
                var xd = ConfigService.GetXD(AyCommon.ToInt(_1));
                common.LoadCombox_IE(XDCbo, xd);//巷道
                if (xd.Count() == 0)
                    wyyd_left.XDBH = -1;
                else
                    wyyd_left.XDBH = xd.ElementAt(0).XDBH;
            };

            MGchange = inParam =>
            {
                var _1 = inParam;
                var xd = ConfigService.GetXD(AyCommon.ToInt(_1));
                common.LoadCombox_IE(XDCbo1, xd);//巷道
                if (xd.Count() == 0)
                    mg_left.XDBH = -1;
                else
                    mg_left.XDBH = xd.ElementAt(0).XDBH;
            };

            WYYLchange = inParam =>
            {
                var _1 = inParam;
                var xd = ConfigService.GetXD(AyCommon.ToInt(_1));
                common.LoadCombox_IE(XDCbo2, xd);//巷道
                if (xd.Count() == 0)
                    wyyl_left.XDBH = -1;
                else
                    wyyl_left.XDBH = xd.ElementAt(0).XDBH;
            };
            #endregion

            #region 综采事件
            //双击修改
            DoubleRow_ZCYL_Bottom = inParam =>
            {
                if (inParam == null)
                    return;
                var r1 = inParam as ZCYL_Bottom;
                if (zcyl_left.GZMBH == r1.GZMBH)
                    return;
                zcyl_left.ID = r1.ID;
                if (zcyl_left.CQBH != r1.CQBH)
                {
                    zcyl_left.CQBH = r1.CQBH;
                    var gzm = ConfigService.GetGZM(r1.CQBH);
                    common.LoadCombox_IE(GZMCbo, gzm);//工作面
                }
                zcyl_left.GZMBH = r1.GZMBH;
                zcyl_left.YLFJQSBH = r1.YLFJQSBH;
                zcyl_left.YLFJZZBH = r1.YLFJZZBH;
                zcyl_left.FIRSTTD = r1.FIRSTTD;
                zcyl_left.SECONDTD = r1.SECONDTD;
                zcyl_left.THIRDTD = r1.THIRDTD;
                zcyl_left.FIRSTGJ = r1.FIRSTGJ;
                zcyl_left.SECONDGJ = r1.SECONDGJ;
                zcyl_left.THIRDGJ = r1.THIRDGJ;
                zcyl_left.ZJXS = r1.ZJXS;
                zcyl_left.YLSX = r1.YLSX;
                zcyl_left.YLXX = r1.YLXX;
                zcyl_left.SJJLZQ = r1.SJJLZQ;
                zcyl_left.YLBJZ = r1.YLBJZ;
                zcyl_left.WAVEBJ = r1.WAVEBJ;
                zcyl_left.DXBJ = r1.DXBJ;
                zcyl_left.ZJZS = r1.ZJZS;
                //zcyl_left.Csqy = 0;

                Load_ZC(r1.GZMBH,false);
                //string Json = JsonConvert.SerializeObject(S1Model);


            };
            //保存
            SaveZCYL = inParam =>
            {
               // string Json = JsonConvert.SerializeObject(zcyl_left);
                View_ZC_INI_CS css = GetView_ZC_INI_CS();
                #region 数据有效性判断
                if (css.CQBH==-1)
                {
                    AyMessageBox.ShowError("请选择测区！");
                    return;
                }
                if (css.GZMBH == -1)
                {
                    AyMessageBox.ShowError("请选择工作面！");
                    return;
                }
                if (css.YLFJQSBH <= 0 || css.YLFJQSBH> css.YLFJZZBH)
                {
                    AyMessageBox.ShowError("压力分机起始编号应大于0且小于终止编号！");
                    return;
                }
                if (css.YLFJZZBH <= 0)
                {
                    AyMessageBox.ShowError("压力分机终止编号应大于0！");
                    return;
                }
                if (css.FIRSTTD == "-1" || css.FIRSTTD == "不使用")
                {
                    AyMessageBox.ShowError("请选择第一压力通道！");
                    return;
                }
                if (css.FIRSTTD != "不使用" && css.FIRSTGJ <=0)
                {
                    AyMessageBox.ShowError("第一压力缸径应大于0！");
                    return;
                }
                if (css.SECONDTD == "-1" || css.SECONDTD == "不使用")
                {
                    AyMessageBox.ShowError("请选择第二压力通道！");
                    return;
                }
                if (css.SECONDTD != "不使用" && css.SECONDGJ <= 0)
                {
                    AyMessageBox.ShowError("第二压力缸径应大于0！");
                    return;
                }
                if (css.THIRDTD == "-1")
                {
                    AyMessageBox.ShowError("请选择第三压力通道！");
                    return;
                }
                if (css.THIRDTD !="不使用" && css.THIRDGJ <= 0)
                {
                    AyMessageBox.ShowError("第三压力缸径应大于0！");
                    return;
                }
                if (css.THIRDTD == "不使用")
                {
                    css.THIRDGJ = 0;
                    zcyl_left.THIRDGJ=0;
                }
                if (css.YLSX <= 0 || css.YLSX<css.YLXX)
                {
                    AyMessageBox.ShowError("压力上限应大于0且大于等于压力上限！");
                    return;
                }
                if (css.YLXX <= 0)
                {
                    AyMessageBox.ShowError("压力下限应大于0！");
                    return;
                }
                if (css.YLBJZ <= 0)
                {
                    AyMessageBox.ShowError("压力报警值应大于0！");
                    return;
                }
                //if (css.ZJZS <= 0)
                //{
                //    AyMessageBox.ShowError("支架总数应大于0！");
                //    return;
                //}
                if (css.SJJLZQ == "-1")
                {
                    AyMessageBox.ShowError("请选择数据记录周期！");
                    return;
                }
                if (css.ZJXS=="-1")
                {
                    AyMessageBox.ShowError("请选择支架形式！");
                    return;
                }
                #endregion

                var ylfj = Datas_ZCYL_Right;// ConfigService.GetZcWz(gzmbh);// Db.Query<ZCYLFJWZB>();//" where GZMBH=@gzmbh", gzmbh
                if (ylfj.Count == 0)
                {
                    int rst = ConfigService.SaveZc(css, null);
                    if (rst==-1)
                    {
                        AyMessageBox.ShowError("采集器编号已被其他工作面占用！");
                    }
                    else
                    {
                        Load_ZC(css.GZMBH,true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功": "添加成功");
                    }
                }
                else
                {
                    List<ZCYLFJWZB> L = new List<ZCYLFJWZB>();
                    foreach (var r_ylfj in Datas_ZCYL_Right)
                    {
                        ZCYLFJWZB r = new ZCYLFJWZB();
                        //r.GZMBH = r_ylfj.GZMBH;
                        r.YLFJBH = r_ylfj.YLFJBH;
                        r.DYZJBH = r_ylfj.DYZJBH;
                        r.SBBM = r_ylfj.SBBM;
                        r.WZ = r_ylfj.WZ;
                        r.SYZT = r_ylfj.SYZT;
                        L.Add(r);
                    }
                    int rst = ConfigService.SaveZc(css, L);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("采集器编号已被其他工作面占用！");
                    }
                    else
                    {
                        Load_ZC(css.GZMBH,true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
            };
            //保存
            SaveItem_ZCYL_Right = inParam =>
            {
                //RowOldNewValue _13 = AyTableViewService.GetRowObject(inParam.ToObjectString());
                //if (_13 == null) return;
                ////保存
                //var _3 = _13.OldValue as ZCYL_Right;
                //var _4 = _13.NewValue as ZCYL_Right;
                //foreach (var rr in Datas_ZCYL_Right)
                //{
                //    if (rr.ROWID == _4.ROWID)
                //    { 
                //        rr.WZ = _4.WZ;
                //        rr.SYZT = _4.SYZT; 
                //    }
                //}
                //AyMessageBox.ShowRight("保存右边单条成功,需要点击下面保存生效！");
            };
            #endregion

            #region 围岩移动事件

            DBLCchecked = inParam =>
            {
                wyyd_left.CQBH = -1;
                wyyd_left.XDBH = -1;
                wyyd_left.CGQLX = "LC";
                Load_WYYD(0, true);
                AYUI.Message.Send<object>("顶板离层！", MESSAGES.IsDBLC);

            };

            DBLCUnchecked = inParam =>
            {
                wyyd_left.CQBH = -1;
                wyyd_left.XDBH = -1;
                wyyd_left.CGQLX = "XC";
                Load_WYYD(0, true);
                AYUI.Message.Send<object>("顶板下层！", MESSAGES.IsDBXC);
            };

            DoubleRow_WYYD_Bottom = inParam =>
            {
                if (inParam == null)
                    return;
                var r1 = inParam as WYYD_Bottom;
                if (wyyd_left.XDBH == r1.XDBH || r1.CGQLX!= wyyd_left.CGQLX)
                    return;
                //wyyd_left.Csqy = 1;//测试区域没有
                wyyd_left.ID = r1.ID;
                if (wyyd_left.CQBH != r1.CQBH)
                {
                    wyyd_left.CQBH = r1.CQBH;
                    var xd = ConfigService.GetXD(r1.CQBH);
                    common.LoadCombox_IE(XDCbo, xd);//巷道
                }
                wyyd_left.XDBH = r1.XDBH;
                wyyd_left.CGQLX = r1.CGQLX;
                wyyd_left.CGQQSBH = r1.CGQQSBH;
                wyyd_left.CGQZZBH = r1.CGQZZBH;
                wyyd_left.WYBJZ = r1.WYBJZ;
                wyyd_left.SDBJZ = r1.SDBJZ;
                wyyd_left.SJJLZQ = r1.SJJLZQ;
                wyyd_left.WAVEBJ = r1.WAVEBJ;
                wyyd_left.DXBJ = r1.DXBJ;
                //if (r1.CGQLX == "LC")
                //    wyyd_left.IsLC = true;
                //else if (r1.CGQLX == "XC")
                //    wyyd_left.IsXC = true;
                Load_WYYD(r1.XDBH,false);
            };
            SaveWYYD = inParam =>
            {
               // string Json = JsonConvert.SerializeObject(wyyd_left);
                View_DBLC_INI_CS css = GetView_DBLC_INI_CS();
                #region 数据有效性判断
                if (css.CQBH == -1)
                {
                    AyMessageBox.ShowError("请选择测区！");
                    return;
                }
                if (css.XDBH == -1)
                {
                    AyMessageBox.ShowError("请选择巷道！");
                    return;
                }
                if (css.CGQQSBH <= 0 || css.CGQQSBH > css.CGQZZBH)
                {
                    AyMessageBox.ShowError("传感器起始编号应大于0且小于终止编号！");
                    return;
                }
                if (css.CGQZZBH <= 0)
                {
                    AyMessageBox.ShowError("传感器终止编号应大于0！");
                    return;
                }
                if (css.WYBJZ <= 0)
                {
                    AyMessageBox.ShowError("位移报警值应大于0！");
                    return;
                }
                if (css.SJJLZQ == "-1")
                {
                    AyMessageBox.ShowError("请选择数据记录周期！");
                    return;
                }
                #endregion
                var ylfj = Datas_WYYD_Right;// ConfigService.GetZcWz(gzmbh);// Db.Query<ZCYLFJWZB>();//" where GZMBH=@gzmbh", gzmbh
                if (ylfj.Count == 0)
                {
                    int rst = ConfigService.SaveDblc(css, null);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_WYYD(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
                else
                {
                    List<DBLCCGQWZB> L = new List<DBLCCGQWZB>();
                    foreach (var r_ylfj in Datas_WYYD_Right)
                    {
                        DBLCCGQWZB r = new DBLCCGQWZB();
                        r.XDBH = r_ylfj.XDBH;
                        r.CGQBH = r_ylfj.CGQBH;
                        r.CGQLX = r_ylfj.CGQLX;
                        r.CGQWZ = r_ylfj.CGQWZ;
                        r.AJDSD = r_ylfj.AJDSD;
                        r.BJDSD = r_ylfj.BJDSD;
                        r.SYZT = r_ylfj.SYZT;
                        L.Add(r);
                    }
                    int rst = ConfigService.SaveDblc(css, L);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_WYYD(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
            };
            //围岩-右边
            SaveItem_WYYD_Right = inParam =>
            {
                //RowOldNewValue _13 = AyTableViewService.GetRowObject(inParam.ToObjectString());
                //if (_13 == null) return;

                ////保存
                //var _3 = _13.OldValue as WYYD_Right;
                //var _4 = _13.NewValue as WYYD_Right;

                //foreach (var rr in Datas_WYYD_Right)
                //{
                //    if (rr.ROWID == _4.ROWID)
                //    {
                //        rr.CGQWZ = _4.CGQWZ;
                //        rr.AJDSD = _4.AJDSD;
                //        rr.BJDSD = _4.BJDSD;
                //        rr.SYZT = _4.SYZT;
                //    }
                //}
                //AyMessageBox.ShowRight("保存围岩移动-右边成功，需要点击下面保存生效!" );
            };

            #endregion

            #region 锚杆事件
            //锚杆-底部
            DoubleRow_MG_Bottom = inParam =>
            {
                if (inParam == null)
                    return;
                var r1 = inParam as MG_Bottom;
                if (mg_left.XDBH == r1.XDBH)
                    return;
                mg_left.ID = r1.ID;
                if (mg_left.CQBH != r1.CQBH)
                {
                    mg_left.CQBH = r1.CQBH;
                    var xd = ConfigService.GetXD(r1.CQBH);
                    common.LoadCombox_IE(XDCbo1, xd);//工作面
                }
                mg_left.XDBH = r1.XDBH;
                mg_left.CGQQSBH = r1.CGQQSBH;
                mg_left.CGQZZBH = r1.CGQZZBH;
                mg_left.MGBJZ = r1.MGBJZ;
                mg_left.MSBJZ = r1.MSBJZ;
                mg_left.MGCSYJL = r1.MGCSYJL;
                mg_left.MSCSYJL = r1.MSCSYJL;
                mg_left.SJJLZQ = r1.SJJLZQ;
                mg_left.WAVEBJ = r1.WAVEBJ;
                mg_left.DXBJ = r1.DXBJ;
                Load_MG(r1.XDBH,false);

            };

            SaveMG = inParam =>
            {
                //string Json = JsonConvert.SerializeObject(mg_left);
                View_MG_INI_CS css =   GetView_MG_INI_CS();
                #region 数据有效性判断
                if (css.CQBH == -1)
                {
                    AyMessageBox.ShowError("请选择测区！");
                    return;
                }
                if (css.XDBH == -1)
                {
                    AyMessageBox.ShowError("请选择巷道！");
                    return;
                }
                if (css.CGQQSBH <= 0 || css.CGQQSBH > css.CGQZZBH)
                {
                    AyMessageBox.ShowError("传感器起始编号应大于0且小于终止编号！");
                    return;
                }
                if (css.CGQZZBH <= 0)
                {
                    AyMessageBox.ShowError("传感器终止编号应大于0！");
                    return;
                }
                if (css.MGCSYJL < 0)
                {
                    AyMessageBox.ShowError("锚杆初始预紧力应大于等于0！");
                    return;
                }
                if (css.MGBJZ < 0)
                {
                    AyMessageBox.ShowError("锚杆报警值应大于等于0！");
                    return;
                }
                if (css.MSCSYJL < 0)
                {
                    AyMessageBox.ShowError("锚索初始预紧力应大于等于0！");
                    return;
                }
                if (css.MSBJZ < 0)
                {
                    AyMessageBox.ShowError("锚索报警值应大于等于0！");
                    return;
                }
                if (css.SJJLZQ == "-1")
                {
                    AyMessageBox.ShowError("请选择数据记录周期！");
                    return;
                }
                #endregion
                var ylfj = Datas_MG_Right;// ConfigService.GetZcWz(gzmbh);// Db.Query<ZCYLFJWZB>();//" where GZMBH=@gzmbh", gzmbh
                if (ylfj.Count == 0)
                {
                    int rst = ConfigService.SaveMg(css, null);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_MG(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
                else
                {
                    List<MGYLCGQWZB> L = new List<MGYLCGQWZB>();
                    foreach (var r_ylfj in Datas_MG_Right)
                    {
                        MGYLCGQWZB r = new MGYLCGQWZB();
                        r.XDBH = r_ylfj.XDBH;
                        r.CGQBH = r_ylfj.CGQBH;
                        r.CGQLX = r_ylfj.CGQLX;
                        r.CGQWZ = r_ylfj.CGQWZ;
                        r.MGZJ = r_ylfj.MGZJ;
                        r.SYZT = r_ylfj.SYZT;
                        L.Add(r);
                    }
                    int rst = ConfigService.SaveMg(css, L);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_MG(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
            };
            //锚杆-右边
            SaveItem_MG_Right = inParam =>
            {
                //RowOldNewValue _13 = AyTableViewService.GetRowObject(inParam.ToObjectString());
                //if (_13 == null) return;
                //var _4 = _13.NewValue as MG_Right; 
                //foreach (var r in Datas_MG_Right)
                //{
                //    if (r.ROWID == _4.ROWID)
                //    {
                //        r.CGQLX = _4.CGQLX;
                //        r.SYZT = _4.SYZT;
                //    }
                //} 
                //AyMessageBox.ShowRight("保存锚杆-右边成功，需要点击下面保存生效!" );
            };

            //锚杆报警值计算
            ChangeBJZ = inParam =>
            {
                var _1 = inParam;
                ConditonsModel.TYPE = _1.ToString();
                ShowNavigationWindow("抗拉强度计算", "/Views/ZCYL/System_para_Computer.xaml", 400, 300);
            };

            #endregion

            #region 围岩应力事件
            DoubleRow_WYYL_Bottom = inParam =>
            {
                if (inParam == null)
                    return;
                var r1 = inParam as WYYL_Bottom;
                if (wyyl_left.XDBH == r1.XDBH)
                    return;
                wyyl_left.ID = r1.ID;
                if (wyyl_left.CQBH != r1.CQBH)
                {
                    wyyl_left.CQBH = r1.CQBH;
                    var xd = ConfigService.GetXD(r1.CQBH);
                    common.LoadCombox_IE(XDCbo2, xd);//工作面
                }
                wyyl_left.XDBH = r1.XDBH;
                wyyl_left.CGQQSBH = r1.CGQQSBH;
                wyyl_left.CGQZZBH = r1.CGQZZBH;
                wyyl_left.CQCSYY = r1.CQCSYY;
                wyyl_left.SJJLZQ = r1.SJJLZQ;
                Load_WYYL(r1.XDBH,false);
            };

            SaveWYYL = inParam =>
            {
                //string Json = JsonConvert.SerializeObject(wyyl_left);
                View_CQYL_INI_CS css = GetView_CQYL_INI_CSS();
                #region 数据有效性判断
                if (css.CQBH == -1)
                {
                    AyMessageBox.ShowError("请选择测区！");
                    return;
                }
                if (css.XDBH == -1)
                {
                    AyMessageBox.ShowError("请选择巷道！");
                    return;
                }
                if (css.CGQQSBH <= 0 || css.CGQQSBH > css.CGQZZBH)
                {
                    AyMessageBox.ShowError("传感器起始编号应大于0且小于终止编号！");
                    return;
                }
                if (css.CGQZZBH <= 0)
                {
                    AyMessageBox.ShowError("传感器终止编号应大于0！");
                    return;
                }
                if (css.CQCSYY < 0)
                {
                    AyMessageBox.ShowError("初始预压应大于等于0！");
                    return;
                }
                if (css.SJJLZQ == "-1")
                {
                    AyMessageBox.ShowError("请选择数据记录周期！");
                    return;
                }
                #endregion
                var ylfj = Datas_WYYL_Right;// ConfigService.GetZcWz(gzmbh);// Db.Query<ZCYLFJWZB>();//" where GZMBH=@gzmbh", gzmbh
                if (ylfj.Count == 0)
                {
                    int rst = ConfigService.SaveCqyl(css, null);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_WYYL(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }
                else
                {
                    List<CQYLCGQWZB> L = new List<CQYLCGQWZB>();
                    foreach (var R in Datas_WYYL_Right)
                    {
                        CQYLCGQWZB r = new CQYLCGQWZB();
                        r.CGQBH = R.CGQBH;
                        r.XDBH = R.XDBH;
                        r.CGQBH = R.CGQBH;
                        r.SD = R.SD;
                        r.CGQWZ = R.CGQWZ;
                        r.SYZT = R.SYZT;
                        L.Add(r);
                    }
                    int rst = ConfigService.SaveCqyl(css, L);
                    if (rst == -1)
                    {
                        AyMessageBox.ShowError("传感器编号已被其他巷道占用！");
                    }
                    else
                    {
                        Load_WYYL(css.XDBH, true);
                        AyMessageBox.ShowInformation(rst == 0 ? "修改成功" : "添加成功");
                    }
                }

            };
            //围岩应力-右边
            SaveItem_WYYL_Right = inParam =>
            {
                //RowOldNewValue _13 = AyTableViewService.GetRowObject(inParam.ToObjectString());
                //if (_13 == null) return;
                //var _4 = _13.NewValue as WYYL_Right;
                //foreach (var r in Datas_WYYL_Right)
                //{
                //    if (r.ROWID == _4.ROWID)
                //    {
                //        r.CGQWZ = _4.CGQWZ;
                //        r.SYZT = _4.SYZT;
                //    }
                //} 
                //AyMessageBox.ShowRight("保存围岩应力-右边成功，需要点击下面保存生效!!" );
            };
            #endregion
        }

        private void LoadUI()
        {
            Dictionary<string, string> D_CQ = new Dictionary<string, string>();
            D_CQ.Add("前柱", "前柱");
            D_CQ.Add("后柱", "后柱");
            D_CQ.Add("左柱", "左柱");
            D_CQ.Add("右柱", "右柱");
            //D_CQ.Add("前探梁", "前探梁");
            //D_CQ.Add("平衡千斤顶", "平衡千斤顶");
            //D_CQ.Add("推溜千斤顶", "推溜千斤顶");
            var cq = ConfigService.GetCQ(false);
            common.LoadCombox_IE(CSCob, cq);//测区
           
            common.LoadCombox(FirCbo, D_CQ);//第一道
            common.LoadCombox(SecCbo, D_CQ);//第二道
            D_CQ.Add("不使用", "不使用");
            common.LoadCombox(ThirdCbo, D_CQ);//第三道
            Dictionary<string, string> D_write = new Dictionary<string, string>();
            D_write.Add("5", "5");
            D_write.Add("10", "10");
            D_write.Add("20", "20");
            D_write.Add("30", "30");
            common.LoadCombox(WriteCbo, D_write);//记录周期
            Dictionary<string, string> D_sytel = new Dictionary<string, string>();
            D_sytel.Add("两柱式", "两柱式");
            D_sytel.Add("四柱式", "四柱式");  
            common.LoadCombox(StyleCbo, D_sytel);//支架形式
            
            common.LoadCombox(CSYJCbo, D_write);//初始预警值(暂时未处理）
            common.LoadCombox(BJZCbo, D_write);//报警值
            Dictionary<string, string> D_LX = new Dictionary<string, string>();
            //D_LX.Add("LC", "离层");
            //D_LX.Add("XC", "下沉");
            D_LX.Add("MG", "锚杆");
            D_LX.Add("MS", "锚索");  
            common.LoadCombox(LXCbo, D_LX);//类型
            LXCbo.RemoveAt(0);

            common.LoadCombox_Status(ZTCbo);//状态 
            
            common.LoadCombox_WZ(WZCbo);//位置
        }
        /// <summary>
        /// 加载综采列表或压力分机列表数据
        /// </summary>
        /// <param name="gzmbh">工作面编号，大于0时刷新右侧列表</param>
        /// <param name="refreshList">是否刷新底部列表</param>

        void Load_ZC(int gzmbh, bool refreshList)
        {
            if (refreshList)
            {
                var cqr = ConfigService.GetZc();
                Datas_ZCYL_Bottom.Clear();
                foreach (var r1 in cqr)
                {
                    ZCYL_Bottom ct = new ZCYL_Bottom();
                    ct.ID = r1.ID;
                    ct.CQBH = r1.CQBH;
                    ct.GZMBH = r1.GZMBH;
                    ct.GZMMC = r1.GZMMC;
                    ct.YLFJQSBH = r1.YLFJQSBH;
                    ct.YLFJZZBH = r1.YLFJZZBH;
                    ct.FIRSTTD = r1.FIRSTTD;
                    ct.SECONDTD = r1.SECONDTD;
                    ct.THIRDTD = r1.THIRDTD;
                    ct.FIRSTGJ = r1.FIRSTGJ;
                    ct.SECONDGJ = r1.SECONDGJ;
                    ct.THIRDGJ = r1.THIRDGJ;
                    ct.ZJXS = r1.ZJXS;
                    ct.YLSX = r1.YLSX;
                    ct.YLXX = r1.YLXX;
                    ct.SJJLZQ = r1.SJJLZQ;
                    ct.YLBJZ = r1.YLBJZ;
                    ct.WAVEBJ = r1.WAVEBJ;
                    ct.DXBJ = r1.DXBJ;
                    ct.ZJZS = r1.ZJZS;
                    //ct.WIDTH = r1.WIDTH;
                    //ct.LENGTH = r1.LENGTH;
                    //ct.FIELD1 = r1.FIELD1; 
                    Datas_ZCYL_Bottom.Add(ct);
                }
            }
            if(gzmbh > 0)
            {
                var ylfj = ConfigService.GetZcWz(gzmbh);// Db.Query<ZCYLFJWZB>();//" where GZMBH=@gzmbh", gzmbh
                Datas_ZCYL_Right.Clear();
 
                foreach (var r_ylfj in ylfj)
                {
                    ZCYL_Right r = new ZCYL_Right();
                    r.GZMBH = r_ylfj.GZMBH;
                    r.YLFJBH = r_ylfj.YLFJBH;
                    r.DYZJBH = r_ylfj.DYZJBH;
                    r.SBBM = r_ylfj.SBBM;
                    r.WZ = r_ylfj.WZ;
                    r.SYZT = r_ylfj.SYZT; 
                    Datas_ZCYL_Right.Add(r);
                }
            }

        }

        /// <summary>
        /// 围岩移动
        /// </summary>
        /// <param name="xdbh"></param>
        /// <param name="refreshList">是否刷新底部列表</param>
        void Load_WYYD(int xdbh, bool refreshList)
        {
            if (refreshList)
            {
                var cqr = ConfigService.GetDblc(wyyd_left.IsLC);
                Datas_WYYD_Bottom.Clear();
                foreach (var r1 in cqr)
                {
                    WYYD_Bottom w_b = new WYYD_Bottom();
                    w_b.CQBH = r1.CQBH;
                    w_b.ID = r1.ID;
                    w_b.XDBH = r1.XDBH;
                    w_b.XDMC = r1.XDMC;
                    w_b.CGQLX = r1.CGQLX;
                    w_b.CGQQSBH = r1.CGQQSBH;
                    w_b.CGQZZBH = r1.CGQZZBH;
                    w_b.WYBJZ = r1.WYBJZ;
                    w_b.SDBJZ = r1.SDBJZ;
                    w_b.SJJLZQ = r1.SJJLZQ;
                    w_b.WAVEBJ = r1.WAVEBJ;
                    w_b.DXBJ = r1.DXBJ;
                    w_b.CQMC = r1.CQMC;
                    Datas_WYYD_Bottom.Add(w_b);
                }
            }
            //if(xdbh!=0)
            {
                var ylfj = ConfigService.GetDblcWz(xdbh,wyyd_left.IsLC); //Db.Query<DBLCCGQWZB>();//" where XDBH=@gzmbh", XDBH
                Datas_WYYD_Right.Clear(); 
                foreach (var r_ylfj in ylfj)
                {
                    WYYD_Right r = new WYYD_Right();
                    r.XDBH = r_ylfj.XDBH;
                    r.CGQBH = r_ylfj.CGQBH;
                    r.CGQLX = r_ylfj.CGQLX;
                    r.CGQWZ = r_ylfj.CGQWZ;
                    r.AJDSD = r_ylfj.AJDSD;
                    r.BJDSD = r_ylfj.BJDSD; 
                    r.SYZT = r_ylfj.SYZT;
                    Datas_WYYD_Right.Add(r);
                }
            }
        }
        /// <summary>
        /// 锚杆
        /// </summary>
        /// <param name="xdbh">巷道编号</param>
        /// <param name="refreshList">是否刷新底部列表</param>
        void Load_MG(int xdbh, bool refreshList)
        {
            if (refreshList)
            {
                var cqr = ConfigService.GetMg();
                Datas_MG_Bottom.Clear();
                foreach (var r1 in cqr)
                {
                    MG_Bottom w_b = new MG_Bottom();
                     
                    w_b.CQBH = r1.CQBH;
                    w_b.CQMC = r1.CQMC;
                    w_b.ID = r1.ID;
                    w_b.XDBH = r1.XDBH;
                    w_b.XDMC = r1.XDMC;
                    w_b.CGQQSBH = r1.CGQQSBH;
                    w_b.CGQZZBH = r1.CGQZZBH;
                    w_b.MGBJZ = r1.MGBJZ;
                    w_b.MSBJZ = r1.MSBJZ;
                    w_b.MGCSYJL = r1.MGCSYJL;
                    w_b.MSCSYJL = r1.MSCSYJL;
                    w_b.SJJLZQ = r1.SJJLZQ;
                    w_b.WAVEBJ = r1.WAVEBJ;
                    w_b.DXBJ = r1.DXBJ;
                    Datas_MG_Bottom.Add(w_b);
                }
            }
            //if(xdbh!=0)
            {
                var ylfj = ConfigService.GetMgWz(xdbh);// Db.Query<MGYLCGQWZB>();//" where XDBH=@gzmbh", XDBH
                Datas_MG_Right.Clear();
                foreach (var r_ylfj in ylfj)
                {
                    MG_Right r = new MG_Right();
                    r.XDBH = r_ylfj.XDBH;
                    r.CGQBH = r_ylfj.CGQBH;
                    r.CGQLX = r_ylfj.CGQLX;
                    r.CGQWZ = r_ylfj.CGQWZ;
                    r.MGZJ = r_ylfj.MGZJ; 
                    r.SYZT = r_ylfj.SYZT;
                    Datas_MG_Right.Add(r);
                }
            }
        }

        /// <summary>
        /// 围岩应力
        /// </summary>
        /// <param name="xdbh"></param>
        /// <param name="refreshList">是否刷新底部列表</param>
        void Load_WYYL(int xdbh, bool refreshList)
        {
            if (refreshList)
            {
                var cqr = ConfigService.GetCqyl();
                Datas_WYYL_Bottom.Clear();
                foreach (var r1 in cqr)
                {
                    WYYL_Bottom w_b = new WYYL_Bottom(); 
                    w_b.ID = r1.ID;
                    w_b.CQBH = r1.CQBH;
                    w_b.CQMC = r1.CQMC;
                    w_b.XDBH = r1.XDBH;
                    w_b.XDMC = r1.XDMC;
                    w_b.CGQQSBH = r1.CGQQSBH;
                    w_b.CGQZZBH = r1.CGQZZBH;
                    w_b.CQCSYY = r1.CQCSYY;
                    w_b.SJJLZQ = r1.SJJLZQ; 
                    Datas_WYYL_Bottom.Add(w_b);
                }
            }
            //if(xdbh!=0)
            {

                var ylfj = ConfigService.GetCqylWz(xdbh);// Db.Query<CQYLCGQWZB>();//" where XDBH=@gzmbh", XDBH
                Datas_WYYL_Right.Clear();
                foreach (var r_ylfj in ylfj)
                {
                    WYYL_Right r = new WYYL_Right();
                    r.XDBH = r_ylfj.XDBH;
                    r.CGQBH = r_ylfj.CGQBH;
                    r.SD = r_ylfj.SD;
                    r.CGQWZ = r_ylfj.CGQWZ; 
                    r.SYZT = r_ylfj.SYZT;
                    Datas_WYYL_Right.Add(r);
                }
            }
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        public void LoadData()
        {
          
            AyThread.Instance.RunNew(() =>
             {

                //加载动画开始
                ViewBag.IsBusy = true;

                 #region  综采
                 zcyl_left.GZMBH = 0;
                 zcyl_left.YLFJZZBH = 10;
                 Load_ZC(0,true);

                 #endregion

                 #region 围岩
                 Load_WYYD(0,true);
                 #endregion

                 #region 锚杆

                 Load_MG(0,true);
                 #endregion

                 #region 围岩应力
                 Load_WYYL(0,true);
                 #endregion

                 // 加载停止
                 ViewBag.IsBusy = false;
             });

        }

        #region 综采
      

        /// <summary>
        /// 综采
        /// </summary>
        /// <returns></returns>
        View_ZC_INI_CS GetView_ZC_INI_CS()
        {
            View_ZC_INI_CS zccs = new View_ZC_INI_CS();
            zccs.CQBH = zcyl_left.CQBH;
            zccs.ID = zcyl_left.ID;
            zccs.GZMBH = zcyl_left.GZMBH;
            zccs.YLFJQSBH = zcyl_left.YLFJQSBH;
            zccs.YLFJZZBH = zcyl_left.YLFJZZBH;
            zccs.FIRSTTD = zcyl_left.FIRSTTD;
            zccs.SECONDTD = zcyl_left.SECONDTD;
            zccs.THIRDTD = zcyl_left.THIRDTD;
            zccs.FIRSTGJ = zcyl_left.FIRSTGJ;
            zccs.SECONDGJ = zcyl_left.SECONDGJ;
            zccs.THIRDGJ = zcyl_left.THIRDGJ;
            zccs.ZJXS = zcyl_left.ZJXS;
            zccs.YLSX = zcyl_left.YLSX;
            zccs.YLXX = zcyl_left.YLXX;
            zccs.SJJLZQ = zcyl_left.SJJLZQ;
            zccs.YLBJZ = zcyl_left.YLBJZ;
            zccs.WAVEBJ = zcyl_left.WAVEBJ;
            zccs.DXBJ = zcyl_left.DXBJ;
            zccs.ZJZS = zcyl_left.ZJZS;

            return zccs;
        }
        
        /// <summary>
        /// 围岩移动
        /// </summary>
        /// <returns></returns>
        View_DBLC_INI_CS GetView_DBLC_INI_CS()
        {
            View_DBLC_INI_CS w_b = new View_DBLC_INI_CS();
           
           // w_b.Csqy = 1;//测试区域没有
            w_b.ID =  wyyd_left.ID;
            w_b.CQBH = wyyd_left.CQBH;
            w_b.XDBH =  wyyd_left.XDBH;
            w_b.CGQLX = wyyd_left.CGQLX;
            w_b.CGQQSBH =  wyyd_left.CGQQSBH;
            w_b.CGQZZBH =  wyyd_left.CGQZZBH;
            w_b.WYBJZ =  wyyd_left.WYBJZ;
            w_b.SDBJZ =  wyyd_left.SDBJZ;
            w_b.SJJLZQ =  wyyd_left.SJJLZQ;
            w_b.WAVEBJ =  wyyd_left.WAVEBJ;
            w_b.DXBJ =  wyyd_left.DXBJ;
            return w_b;
        }
        /// <summary>
        /// 锚杆
        /// </summary>
        /// <returns></returns>
        View_MG_INI_CS GetView_MG_INI_CS()
        {
            View_MG_INI_CS w_b = new View_MG_INI_CS();
             
            //w_b.Csqy = 1;//测试区域没有
            w_b.ID =  mg_left.ID;
            w_b.CQBH = mg_left.CQBH;
            w_b.XDBH =  mg_left.XDBH;
            w_b.CGQQSBH =  mg_left.CGQQSBH;
            w_b.CGQZZBH =  mg_left.CGQZZBH;
            w_b.MGBJZ =  mg_left.MGBJZ;
            w_b.MSBJZ =  mg_left.MSBJZ;
            w_b.MGCSYJL =  mg_left.MGCSYJL;
            w_b.MSCSYJL =  mg_left.MSCSYJL;
            w_b.SJJLZQ =  mg_left.SJJLZQ;
            w_b.WAVEBJ =  mg_left.WAVEBJ;
            w_b.DXBJ =  mg_left.DXBJ;

            return w_b;
        }
        /// <summary>
        /// 围岩应力
        /// </summary>
        /// <returns></returns>
        View_CQYL_INI_CS GetView_CQYL_INI_CSS()
        {
            View_CQYL_INI_CS w_b = new View_CQYL_INI_CS();

            w_b.ID = wyyl_left.ID;
            w_b.CQBH = wyyl_left.CQBH;
            w_b.XDBH = wyyl_left.XDBH;
            w_b.CGQQSBH = wyyl_left.CGQQSBH;
            w_b.CGQZZBH = wyyl_left.CGQZZBH;
            w_b.CQCSYY = wyyl_left.CQCSYY;
            w_b.SJJLZQ = wyyl_left.SJJLZQ;

            return w_b;
        }
        public ActionResult DoubleRow_ZCYL_Right { get; private set; } = inParam =>
        {
            var _1 = inParam as ZCYL_Right;
            if (_1.IsNotNull())
            {
                string Json = JsonConvert.SerializeObject(_1);
              
                Ay.Framework.WPF.AyMessageBox.Show(Json);
            }
        };
        public ActionResult DoubleRow_ZCYL_Bottom { get; private set; } = inParam =>
        {
            //var _1 = inParam as ZCYL_Left;
            //if (_1.IsNotNull())
            //{
            //    ZCYL_Left z = new ZCYL_Left();
            //      z = _1;
                
            //    string Json = JsonConvert.SerializeObject(_1);  
            //    Ay.Framework.WPF.AyMessageBox.Show(Json);
            //}
        };


        /// <summary>
        ///  保存
        /// </summary>
        public ActionResult SaveZCYL { get; private set; } 
       
       
        /// <summary>
        /// 保存--综采右边
        /// </summary>
        public ActionResult SaveItem_ZCYL_Right { get; private set; }

        #endregion

        #region 围岩
        public ActionResult DoubleRow_WYYD_Bottom { get; private set; }  


        /// <summary>
        /// 左边保存
        /// </summary>
        public ActionResult SaveWYYD { get; private set; }  




        /// <summary>
        /// 保存--综采右边
        /// </summary>
        public ActionResult SaveItem_WYYD_Right { get; private set; }

        #endregion

        #region 锚杆
        public ActionResult MGchange { get; private set; }

        public ActionResult DoubleRow_MG_Bottom { get; private set; } 


        /// <summary>
        /// 左边保存
        /// </summary>
        public ActionResult SaveMG { get; private set; } 



        /// <summary>
        /// 保存--综采右边
        /// </summary>
        public ActionResult SaveItem_MG_Right { get; private set; }

        #endregion
        #region 围岩应力
        public ActionResult DoubleRow_WYYL_Bottom { get; private set; }  

        /// <summary>
        /// 左边保存
        /// </summary>
        public ActionResult SaveWYYL { get; private set; } 




        /// <summary>
        /// 保存--综采右边
        /// </summary>
        public ActionResult SaveItem_WYYL_Right { get; private set; }

        #endregion

        //测区编号改变 ，工作面也改变
        public ActionResult CQchange { get; private set; }
        public ActionResult WYYDchange { get; private set; }
        public ActionResult DBLCchecked { get; private set; }
        public ActionResult DBLCUnchecked { get; private set; }

        public ActionResult WYYLchange { get; private set; }

        /// <summary>
        /// 锚杆报警值
        /// </summary>
        public ActionResult ChangeBJZ { get; private set; }

        public static NavigationWindow window = null;
        /// <summary>/// 使用NavigationWindow弹出页面/// </summary>

        private void ShowNavigationWindow(  string title, string uri, int width, int height)
        {
          
            window = new NavigationWindow();
            window.Title = title;
            window.Width = width;
            window.Height = height;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ResizeMode = ResizeMode.NoResize;
            window.Source = new Uri(uri, UriKind.Relative);
            window.ShowsNavigationUI = false;
            window.Closing += Window_Closing1;

            window.ShowDialog();
        }

        private void Window_Closing1(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if(ConditonsModel.Name==null || ConditonsModel.Name=="")
            {
                return;
            }
            if (ConditonsModel.TYPE=="mg")
                mg_left.MGBJZ = (int)( double.Parse(ConditonsModel.Name));
            else if (ConditonsModel.TYPE == "ms")
                mg_left.MSBJZ = (int)(double.Parse(ConditonsModel.Name));
        }
    }
}
